package com.example.healthcondition.mapper;

import com.example.healthcondition.entity.ExerciseRecords;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ExerciseMapper {

    //插入运动记录
    @Insert("INSERT INTO exerciserecords (user_id, exercise_type, duration, calories_burned, recorded_at) " +
            "VALUES (#{userId}, #{exerciseType}, #{duration}, #{caloriesBurned}, #{recordedAt})")
    @Options(useGeneratedKeys = true, keyProperty = "recordId")
    int insert(ExerciseRecords exerciseRecord);

    // 更新运动记录
    @Update("UPDATE exerciserecords SET exercise_type = #{exerciseType}, duration = #{duration}, " +
            "calories_burned = #{caloriesBurned}, recorded_at = #{recordedAt} WHERE record_id = #{recordId}")
    int update(ExerciseRecords exerciseRecord);

    // 删除运动记录
    @Delete("DELETE FROM exerciserecords WHERE record_id = #{recordId}")
    int delete(int recordId);
}